package space.sakana.edusysback.emu;

import space.sakana.edusysback.entity.question.type.*;

import java.nio.channels.MulticastChannel;

public enum QuestionEnum {
    SINGLE_CHOICE,
    MULTIPLE_CHOICE,
    TRUE_FALSE_Q,
    ESSAY_QUESTION;

    public String getQuestionType(){
        return switch (this) {
            case SINGLE_CHOICE -> "单选题";
            case MULTIPLE_CHOICE -> "多选题";
            case TRUE_FALSE_Q -> "判断题";
            case ESSAY_QUESTION -> "简答题";
        };
    }

    public int getQuestionInt(){
        return switch (this) {
            case SINGLE_CHOICE -> 0;
            case MULTIPLE_CHOICE -> 1;
            case TRUE_FALSE_Q -> 2;
            case ESSAY_QUESTION -> 3;
            default -> -1;
        };
    }

    public static QuestionEnum getQuestionEnum(int type){
        return switch (type) {
            case 0 -> SINGLE_CHOICE;
            case 1 -> MULTIPLE_CHOICE;
            case 2 -> TRUE_FALSE_Q;
            case 3 -> ESSAY_QUESTION;
            default -> null;
        };
    }

    public static Class<? extends QuestionBase> getQuestionClass(int type){
        return switch (type) {
            case 0 -> SingleChoice.class;
            case 1 -> MultipleChoice.class;
            case 2 -> TrueFalseQ.class;
            case 3 -> EssayQuestion.class;
            default -> null;
        };
    }

}
